﻿@using XiaoYuStock.Model
@using XiaoYuStock.Model.Models
@using XiaoYuStock.Model.Request
@using XiaoYuStock.WebApp.Controls
@model PagedList<XiaoYuStock.Model.Entities.HistoryDataModel>
@{
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@section PageSpecificStyleSheetIncludes{
    
}
<div class="row-fluid">
    <div class="span12">
        @using (Html.BeginForm(null, null, null, FormMethod.Get, new { id = "search", @class = "form-inline" }))
        {
            <div class="dataTables_filter">
              <label><button type="submit" class="btn" id="btnSearch">搜索 <i class="icon-search"></i></button></label>
                <label><select id="OrderBy" name="OrderBy" class="m-wrap xsmall"><option value="0" selected="selected">不限</option>
                    <option value="1">涨幅</option>
                    <option value="2">跌幅</option>
                    <option value="3">价高</option>
                    <option value="4">价低</option>
                    </select></label>
                <label>
                    <span>涨幅范围：</span>
                    @Html.TextBox("MinRate", null, new { @class = "m-wrap xsmall" })--@Html.TextBox("MaxRate", null, new { @class = "m-wrap xsmall" })
                </label>
                <label>
                    <span>自选股票：</span>
                    @Html.DropDownList("CustomerCode")
                   
                </label>
                <label>
                    <span>股票代码：</span>
                    @Html.TextBox("ShareCode", null, new { @class = "m-wrap" })
                </label>
                <label>
                    <span>日期：</span>
                    @Html.TextBox("CurrentDate", null, new { @class = "m-wrap small" })
                </label>
            </div>
        }
    </div>
</div>

    <table class="table table-striped table-hover " id="tableHistory">
        <thead>
            <tr>
                <th>
                    项目
                </th>
                <th>
                    日期
                </th>
                <th>
                    低
                </th>
                <th>
                    高
                </th>
                <th>
                    开
                </th>
                <th>
                    收
                </th>
                <th>
                    昨收|涨跌|涨幅
                </th>
               
                <th>振幅</th>
                <th>换手率</th>
                <th>市盈率</th>
                <th>市净率</th>
                <th>
                    成交量(手)
                </th>
                <th>
                    成交金额(万元)
                </th>
                  <th>操作</th>
            </tr>
        </thead>
        <tbody>
            @foreach (var p in Model)
            {
                <tr>
                    <td class="blue">
                        <a target="_blank" href="@Url.Action("Index", "DayData", new
                            {
                                BeginDate = @p.CurrentDate,
                                EndDate =@p.CurrentDate,
                                ShareCode = @p.ShareCode
                            })"  ><span title="@p.ShareName">@(p.ShareName+"("+p.ShareCode+")")</span> </a>
                    </td>
                    <td>
                        <a target="_blank" href="@Url.Action("Index", "HistoryData", new
                            {
                                CustomerCode= @p.ShareCode
                            })">
                            <span class="@(p.OpenAmount < p.CloseAmout ? "red" : "green")">

                                @p.CurrentDate.Substring(5)【@p.WeekDay】
                            </span></a>
</td>
                    <td>
                        <span class="span1">@p.MinAmount</span>
                    </td>
                    <td>
                        <span class="span1">@p.MaxAmount</span>
                    </td>
                    <td>
                        <span class="span1">@p.OpenAmount</span>
                    </td>
                    <td><span class="span1">@p.CloseAmout</span></td>
                    <td>
                        <span>@p.YesterdayCloseAmount</span>|<span class="@(p.DiffPrice>0 ? "red" : "green")">@(p.DiffPrice > 0 ? (p.DiffPrice + "↑" + p.TradeRate + "%") : (p.DiffPrice + "↓" + p.TradeRate + "%"))</span>
                    </td>
                   
                    <td><span>@(Math.Round(p.Amplitude*100,2))%</span></td>
                    <td><span>@(Math.Round(p.TurnoverRate,2))%</span></td>
                    <td><span>@(Math.Round(p.PE ,2))%</span></td>
                    <td><span>@(Math.Round(p.PB,2))%</span></td>
                   
                    <td>
                        <span title="@(p.TradeCount)股">@(p.TradeCount/100)</span>
                    </td>
                    <td class="green">
                        <span title="@(p.TradeAmount)元">@Math.Round(p.TradeAmount / 10000, 2)</span>
                    </td>
                    <td>
                        <a href="javascript:;" onclick="UpdateDayData('@p.ShareCode','@p.CurrentDate')">
                            更新
                        </a>
                        <a class="btn mini purple thickbox" title='分析' href="@Url.Action("ShowDoctor", new { shareCode = p.ShareCode,date=p.TradeTime })&TB_iframe=true&height=400&width=800">
                            <i class="icon-edit"></i>
                            分析
                        </a>
                    </td>
                </tr>
            }
        </tbody>
    </table>

<div class="dataTables_paginate paging_bootstrap pagination">
    @Html.Pager(Model, new PagerOptions() { ShowTotalItemCount = true, AutoHide = false })
</div>
<script>
    $(function () {
        $('#tableHistory').dataTable({
            searching: false,
            bFilter: false,
            bLengthChange: false,
            paging: false,
            bInfo: false,
            bPaginate: false
        });

    });
    String.prototype.trim = function () {

        return this.replace(/(^\s*)|(\s*$)/g, '');
    }
    var dates = $("#CurrentDate").datepicker({
        dateFormat: "yy-mm-dd",
        defaultDate: "+0",
        changeMonth: true,
        changeYear: true,
        numberOfMonths: 1,
        onSelect: function (selectedDate) {
            var option = this.id == "startDate" ? "minDate" : "maxDate",
            instance = $(this).data("datepicker"),
            date = $.datepicker.parseDate(
                instance.settings.dateFormat ||
                $.datepicker._defaults.dateFormat,
                selectedDate, instance.settings);
            dates.not(this).datepicker("option", option, date);
        }
    });
    function UpdateDayData(code)
    {
        $.post("/HistoryData/GetHistoryUpdate", { sharesCodes: code }, function (data) {
            if (data.status) {
                alert("更新完成");
            }
        });
    }

</script>

